package com.woniuxy.third.controller;

import com.woniuxy.third.entity.Sale;
import com.woniuxy.third.entity.User;
import com.woniuxy.third.result.ResponseResult;
import com.woniuxy.third.service.SaleService;
import com.woniuxy.third.utils.GetUserUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author: yangtao
 * @date 2021/7/22 19:18
 * @Version 1.0
 */
@RestController
@RequestMapping("/sale")
public class SaleController {
    @Resource
    private SaleService saleService;

    @GetMapping("/findByUid")
    @ApiOperation(value = "查询卖课 信息", notes = "返回所有信息")
    public ResponseResult<List> findByUid(HttpServletRequest request){
        //根据账户查询到user(调用工具类)
        int uid = GetUserUtil.getUser(request).getId();
        List<Sale> sales=saleService.findByUid(uid);
        return new ResponseResult<>(200, "查询成功", sales);
    }
}
